package com.caration.shell.action;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

import com.caration.shell.R;

public class ActionSelector extends FragmentActivity {
	private static String[] sTitles;
	private SwipeyTabs mSwipeyTabs;
	private ViewPager mViewPager;
	private Intent mIntent;

	public final Intent obtainIntent() {
		return mIntent;
	}

	ViewPager getViewPager() {
		return mViewPager;
	}

	static String[] getTitleArray() {
		return sTitles;
	}

	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.action_selector);
		sTitles = new String[3];
		sTitles[0] = getString(R.string.group_applications);
		sTitles[1] = getString(R.string.group_cmd);
		sTitles[2] = getString(R.string.group_shortcuts);
		mViewPager = ((ViewPager) findViewById(R.id.viewpager));
		mSwipeyTabs = ((SwipeyTabs) findViewById(R.id.swipeytabs));
		FragmentAdapter adapter = new FragmentAdapter(this, this,
				getSupportFragmentManager());
		mViewPager.setAdapter(adapter);
		mSwipeyTabs.setAdapter(adapter);
		mViewPager.setOnPageChangeListener(mSwipeyTabs);
		mViewPager.setCurrentItem(1);

		Intent intent = getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
		if (intent instanceof Intent) {
			mIntent = intent;
		} else {
			mIntent = new Intent(Intent.ACTION_MAIN, null);
			mIntent.addCategory(Intent.CATEGORY_DEFAULT);
		}

		ActionProvider.init(this);
	}
}
